Skip to content

fix(skills): use the 1.2 client's obstacle ray for skill line of sight - #49

Merged
NickMesser merged 3 commits into
NickMesser:rust-rewritefrom
stsiakal:fix/line-of-sight-1.2
Oct 27, 2026
Merged

NickMesser merged 3 commits into
NickMesser:rust-rewritefrom
stsiakal:fix/line-of-sight-1.2

Conversation

@stsiakal

Copy link
Copy Markdown

The cast obstacle check still used the C# ray: +1 m at both ends, static+terrain (0x101), the default 0x8F flags and no radius gate. That rejects casts through obstacles the 1.2 client ignores and misses the client's target-surface shortening.

  • Cast the obstacle ray at unit position height with objtypes 7 (0x107 with check_terrain), ray flags 0x2048F (collision class 2, ignore back faces, pierceability 15) and one hit; a hit maps to 0xC (skill_obstacle) (x2game.dll.c:149877 FUN_390B5540).
  • Shorten the end point by the target radius and cast no ray at all when dist <= radius (FUN_390B5650, x2game.dll.c:149951).
  • Unit targets use the radius at target+0x80 and skip the source and target colliders (FUN_390B5C60 -> FUN_3989C0D0, x2game.dll.c:150156 and :1932675); position (ground) targets use the constant 0.5 (DAT_3999C47C) and skip only the source (FUN_390B5A30 -> FUN_390B5790, x2game.dll.c:150072, :149979, :150024 and :150142).
  • Resolve living proxies in raycast_ignoring_objects: unit colliders live in WorldState::living, not objects, so the ignore list could never skip the caster or target (systems/ai/collision/mod.rs:396). This is a correctness fix for every masked ray; it does not change the skill ray itself, whose mask (7) already excludes living entities.
  • Log obstacle rejections with the character name; the previous base-unit name was empty for players.

The decompile constants were checked directly against D:/aa-re/client12/out-x2game/x2game.dll.c and the unpacked DLL: objtypes 7 / 0x107 at x2game.dll.c:149916-149919, flags 0x2048F at :149930, one hit at :149931, result 0xC at :149939, the radius*radius < dist2 gate at :149965, the target-radius shortening at :149966-149969, the unit target radius at target+0x80 at :1932713-1932717, and the source+target skip in FUN_390B44D0 (:390B44D0); the position path skips only the source (:150113-150123). DAT_3999C47C is the float 0.5 (0x3F000000) in the unpacked DLL and is passed by FUN_390B5A30 at :150142. The multi-part target variant FUN_3989DAE0 (:1933912) is not modelled.

Validation

  • On nick/rust-rewrite (c6befb58c) with only the new test file: cargo test -p aaemu-game obstacle_ray -- --nocapture -> 0 passed, 2 failed. obstacle_ray_matches_the_retail_height_mask_and_collision_class failed at cast_validation_tests.rs:1011 (the old +1 m ray hit a wall above the feet); obstacle_ray_skips_inside_radius_and_uses_the_position_radius failed at :1191 (a thin obstacle inside the target radius still blocked).
  • On fix/line-of-sight-1.2 (b6d08357b): the same command -> 2 passed, 0 failed.
  • cargo test -p aaemu-game cast_validation_tests -> 28 passed, 0 failed.
  • cargo test -p aaemu-game unit_colliders_are_skippable_by_obj_id -> 1 passed, 0 failed. The test hits the living proxy without the ignore entry and passes through it with (ObjKind::Unit, 7); without the living lookup the ignore list is empty and it fails.
  • cargo clippy -p aaemu-game --all-targets -- -D warnings -> passed.
  • Full cargo xtask ci on b6d08357b from rust/ (default test threads): game library 2,881 passed, 0 failed, 149 ignored (8.35 s), exit 0; testclient 57 library + 16 binary; formatting and Clippy clean; coverage ratchet 517 S->C opcodes, 105 without a Rust type, 65 typed but never sent, and 7 Python tests passed. One earlier default-thread run on the previous HEAD hit the timing-sensitive systems::services::shutdown::tests::a_lobby_connection_appearing_during_the_shutdown_gets_the_world_list (None vs Some(false)); it passes standalone, and the final default-thread run above is clean.

Live: a local server stack (live profile, its own databases) was built and started, and a headless GM testclient cast skill 2 in Arach Hollow. The fixed server logged the new feet-height rejection through a doodad (that run predates the name fix, so character= was empty): WARN validation - Skill line of sight blocked character= skill=2 target=17694 result_key="skill_obstacle" ... hit=Hit { ... owner: Some(Object { kind: Doodad, obj_id: 58380 }) }. A controlled before/after cast across a chosen obstacle edge was not reproduced headlessly: runtime-spawned templates 14201/5570/13451 did not appear in the client's unit list, 3492 spawned at an adjusted position and moved, skill 2's Hostile target type returns NO_TARGET for friendly NPCs, and cast moves the caster to 1 m so a pre-placed wall moved with the NPC. The flow tests above are the rule's evidence. The live stack was stopped; no original client was started.

Limits

  • Inferred, not read in the decompile: the client shows only the actor-target path, so doodad, house and slave targets use the same unit semantics here (with radius 0 for doodads); the original's skip of the caster's own vehicle/ship collider is not modelled, so a caster standing on a ship may still be blocked by its hull as before; multi-part targets (FUN_3989DAE0) are not modelled.

  • The unit target radius is model_radius(model_id) * scale; the 1.2 value is target+0x80. Their equality is not proven (the tests inject a radius).

  • The multi-part target variant FUN_3989DAE0 (loops the target's sub-shapes and passes if any part passes) is not modelled; only the single-shape unit path is.

  • The zero-length fallback direction in FUN_390B5650 (dist2 <= epsilon) is not modelled; Rust leaves the end point at the target, which has the same practical outcome.

  • The server's collider world is not the client's render geometry; object type and collision class assignment remain data-dependent.

  • No controlled live obstacle-edge cast is claimed; only the deterministic flow tests and the observed live rejection above.

Review: an independent reviewer (R1) re-read FUN_390B5650, FUN_390B5A30, FUN_390B5790 and the unit path against the new constants, flags and radius gate, the gameplay risk (the new rule is more permissive than the C# ray) and the tests: qualified clear; its wording points are applied.

🤖 Generated with Claude Code

The cast obstacle check still used the C# ray: +1 m at both ends, static+terrain (0x101) and the default 0x8F flags, with no radius gate. The 1.2 client (x2game.dll.c:149877 FUN_390B5540) casts RayWorldIntersection(Game) at unit position height with objtypes 7 (0x107 with check_terrain), flags 0x2048F and one hit; x2game.dll.c:149951 FUN_390B5650 shortens the end point by the target radius and casts no ray when dist <= radius. Unit targets (FUN_390B5C60 -> FUN_3989C0D0) skip the source and target colliders; position targets (FUN_390B5A30 -> FUN_390B5790) use radius 0.5 (DAT_3999C47C) and skip only the source. raycast_ignoring_objects now resolves living proxies, which are stored outside objects, so the unit colliders are actually skipped.

The flow tests cover the height/mask/class rule, the radius gate, the 0.5 m position radius and the terrain gate.
The obstacle ray skips the caster and target colliders. Living proxies live outside objects, so the ignore list must resolve ObjKind::Unit through WorldState::living; this test hits the proxy without the skip and passes through it with the skip, and fails if the lookup only reads objects.
The obstacle warn resolved the caster through with_base_unit, whose name is empty for player characters; prefer the character's unit name and keep the base-unit fallback for NPCs.
@NickMesser
NickMesser merged commit dd900e7 into NickMesser:rust-rewrite Oct 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants